package com.bodu.core.util;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;

public class DateExtUtil {
    /**
     * 得到星期
     * @param date 时间字符串
     * @param format 格式
     * @return
     */
    public static String getWeekDay(String date, String format) {
        if (ObjectUtil.isEmpty(date) && ObjectUtil.isEmpty(format)) {
            return "";
        }
        String[] weekStr = {"星期日", "星期一","星期二","星期三","星期四","星期五","星期六"};
        DateTime dateTime = DateUtil.parse(date, format);
        Integer index = DateUtil.dayOfWeek(dateTime);
        return weekStr[index];
    }
}
